﻿@{
    ViewBag.Title = System.Configuration.ConfigurationManager.AppSettings["AppName"];
    Layout = "~/Views/Shared/_Layout.cshtml";
}
@model Agro.Models.T_User 
<link href="@Url.Content("~/Content/zTreeStyle3.4/zTreeStyle.css")" rel="stylesheet" type="text/css" />
<script src="@Url.Content("~/Scripts/jquery.ztree.all-3.4.min.js")" type="text/javascript"></script>
<style type="text/css">
    .ui-layout-north
    {
        padding: 0px;
        margin: 0px;
        border: 0px;
        background: #208220;
    }
    .ui-layout-west
    {
        padding: 0px;
        margin: 0px;
        border: 0px;
        background: #edfeea;
    }
    .ui-layout-center
    {
        padding: 0px;
        margin: 0px;
        border: 0px;
        overflow: hidden;
    }
    .ui-layout-resizer-north-open
    {
        background-color: #145719;
        border: 0px;
    }
    .ui-layout-resizer-west-open
    {
        background-color: #145719;
    }
     #TableMain
    {
          border-collapse:collapse;
        border:1px solid #ece9d8;
    }
    #TableMain td
    {
         border:1px solid #ece9d8;
         padding:4px;
    }
     .tdcenter
    {
        text-align:center;
    }
</style>
<script language="javascript" type="text/javascript">
    var start;
    var treeObj;
    var parentid;
    var NodeName = "";
    //    var setting = {
    //        data: {
    //            simpleData: { enable: true, idKey: "Menu_ID", pIdKey: "Menu_ParentID" },
    //            key: { name: "Menu_NAME", title: "Menu_NAME" }
    //        },
    //        async: { enable: true, url: "" },
    //        callback: { onClick: zTreeOnClick, onAsyncSuccess: zTreeOnAsyncSuccess, beforeExpand: _zTreeBoforeExpand }
    //    };
    //    function zTreeOnClick(event, treeId, treeNode, clickFlag) {
    //        if (treeNode.Menu_Url == null || treeNode.Menu_Url == 'null' || treeNode.Menu_Url.length == 0) {
    //            return;
    //        }
    //        showloading();
    //       
    //       if (treeNode.TARGET == "_blank") windowsDetail(treeNode.Menu_Url);
    //        else $("#frmPage").attr("src", treeNode.Menu_Url);  //改变frm的URL地址
    //        NodeName = treeNode.Menu_NAME;
    //        setTimeout(function () { hideloading() }, 300);
    //    }
    //    function zTreeOnAsyncSuccess() { }
    //    function _zTreeBoforeExpand(treeId, treeNode) { }
    function loadTree(pid) {
        //        parentid = pid;
        //        treeObj.setting.async.url = "/Home/TreeGetList/" + pid;
        //        treeObj.reAsyncChildNodes(null, "refresh");
        $("#left_menu").html("");
        $.ajax({
            async: false,
            type: "POST",
            url: "/Home/TreeGetList/" + pid,
            //  data: "submitinfoid=" + rowData.SubmitInfo_ID + "&state=" + state,
            success: function (msg) {

                var data = eval(msg);
                $.each(data, function (index, d) {
                    //   <span  class="menu_left">asdfjs</span>
                    // $("#left_menu").append("<div  class=\"menu_left\" url='" + d.Menu_Url + "' >" + d.Menu_NAME + "</div>");
                    var imgurl = d.Menu_Image;
                    if (imgurl == null || imgurl == "null" || imgurl == undefined) {
                        imgurl = "/Content/32/125.png";
                    }
                    $("#left_menu").append("<div   url='" + d.Menu_Url + "' ><table><tr><td valign='top'><img src='" + imgurl + "'/></td><td >" + d.Menu_NAME + "</td></tr></table></div>");

                })



                $("#left_menu div").hover(
                      function () {

                          $(this).addClass("navHover");

                      },
                      function () {
                          if ($(this).attr("isselect") == "true") {

                          }
                          else {
                              $(this).removeClass("navHover");

                          }
                      }
                    );
                $("#left_menu div").click(function () {
                    NodeName = $(this).text();
                    $("#left_menu div").attr("isselect", false);
                    $("#left_menu div").removeClass("navHover");
                    $(this).attr("isselect", true);
                    $(this).addClass("navHover");
                    showloading();

                    $("#frmPage").attr("src", $(this).attr("url"));

                    setTimeout(function () { hideloading() }, 300);
                });
                //如果当前点击菜单不是“首页”，则自动触发左侧第一个菜单
                if (pid != "1")
                    $("#left_menu div:eq(0)").trigger("click");
                else {
                    NodeName = "";
                    if ($("#frmPage").attr("src") != '@Url.Content("~/Home/Default")')//此处判断是为了，防止首次打开页面时，Default页面重复加载。
                        $("#frmPage").attr("src", '@Url.Content("~/Home/Default")');
                }

            }
        });

    }

    $(document).ready(function () {
        $('body').layout({
            applyDemoStyles: false,
            north: { size: 84, spacing_open: 5, closable: false, resizable: false }
                    , west: { size: 200, spacing_open: 1, closable: false, resizable: false }
        });
        //        $.fn.zTree.init($("#treeMenu"), setting);
        //        treeObj = $.fn.zTree.getZTreeObj("treeMenu");
        $("#tab li").hover(
              function () {
                  $(this).addClass("nav2");
              },
              function () {
                  if ($(this).attr("isselect") == "true") {
                  }
                  else
                      $(this).removeClass("nav2");
              }
            );
        $("#tab li").click(function () {
            $("#tab li").attr("isselect", false);
            $("#tab li").removeClass("nav2");
            $(this).attr("isselect", true);
            $(this).addClass("nav2");
            showloading();
//             $("#frmPage").attr("src", $(this).attr("url"));
            loadTree($(this).attr("id"));
            setTimeout(function () { hideloading() }, 300);
        });
        $("#tab ul li:eq(0)").click();





        /*设置loading的位置*/
        var bodywidth = $(document).width();
        var bodyheight = $(document).height();
        $("#loading").css("left", bodywidth / 2 - 110);
        $("#loading").css("top", bodyheight / 2 - 30);
        showtip({ width: 240, height: 140 }, "@Html.Raw(ViewBag.Message)");
        //showtip({ width: 240, height: 140 }, "这里是提示的内容 3秒后关闭<br/><a href='http://www.baidu.com' target='_blank'>我是超链接能打开百度哦</a>");
        setTimeout(function () { hidetip() }, 10000);
        });

    function changePassword() {
        var u = "/SystemManage/User/ChangePassword/";
        parent.asyncbox.open({
            url: u,
            data: '',
            title: "修改密码",
            width: 370,
            height: 216,
            scroll: 'no',
            modal: true,
            btnsbar: parent.$.btn.OKCANCEL, //按钮栏配置请参考 “辅助函数” 中的 $.btn。
            callback: function (action) {
                if (action == 'ok') {
                    var t = this;
                    DialogFrame($(this).attr("id")).Save(t);
                    return false;
                }
                if (action == 'cancel') {

                }
                if (action == 'close') {

                }
            }
        });
    }

    //用来阅读消息
    function SendMessage(id) {
            //发送消息
            var u = "/SystemManage/Message/SendMessage";
            parent.asyncbox.open({
                url: u,
                data: "id="+id,
                title: "阅读消息",
                width: 600,
                height: 380,
                scroll: 'no',
                modal: true,
                btnsbar: parent.$.btn.CANCEL, //按钮栏配置请参考 “辅助函数” 中的 $.btn。
                callback: function (action, opener) {
                 var t = this;
                    if (action == 'ok') {
                        DialogFrame($(this).attr("id")).Save(t);
                        return false;
                    }
                    if (action == 'cancel') {
//                    $(gridId).trigger("reloadGrid");//些处刷新，用以更新阅读状态
//                        return;
                    }
                }
            });
        }

        function GetCycle(cycle) {
        var cyclename="";
        switch(cycle) {
            case "1":
                cyclename="月报"
            break;
        case "2":
            cyclename = "季报"
            break;
        case "3":
            cyclename = "年报"
            break;

        }
    return cyclename;
        }
</script>
<!--头部导航-->
<div class="ui-layout-north" style="display: none;">
    <div class="logo">
    </div>
    <div class="logobg">
    </div>
    <div class="userinfo">
        所属单位:@ViewBag.Organization_Name
        &nbsp;&nbsp;&nbsp;当前用户:@Model.User_Name
        &nbsp;&nbsp;&nbsp;当前在线人数:@ViewBag.OnlineUserNum&nbsp;&nbsp;&nbsp;<a onclick="changePassword()">更改密码</a>&nbsp;&nbsp;&nbsp;<a href="@Url.Content("~/Login/LogOff")">退出</a></div>
    <div id="tab" class="tab">
        <ul>
            @foreach (Agro.Models.T_Menu menu in ViewBag.MenuList)
            {
                <li class="nav1" url="@menu.Menu_Url" id="@menu.Menu_ID"><span class="menu">@menu.Menu_NAME</span></li>
            }
        </ul>
    </div>
</div>
<!--左侧导航-->
<div class="ui-layout-west  navPanelMini" style="display: none;" id='left_menu'>
    @*   <ul id="treeMenu" class="ztree">
    </ul>*@
</div>
<!--主窗体-->
<div class="ui-layout-center" style="display: none;">
    <iframe id='frmPage' src="@Url.Content("~/Home/Default")" frameborder='0' width='100%' height='100%'
            marginheight='0' marginwidth='0' scrolling="auto" style="margin: 0px; margin-bottom: -2px;" onload="hideloading()">
    </iframe>
</div>
<div id="qq_tip" class="asyncbox_auto" style="bottom: -153px; right: 5px; z-index: 1988;
    width: 214px; height: 153px;">
    <table class="asyncbox_table" border="0" cellspacing="0" cellpadding="0">
        <tbody>
            <tr>
                <td class="b_t_l" id="asyncbox_1988_left">
                </td>
                <td class="b_t_m" id="asyncbox_1988_header">
                    <div class="asyncbox_title">
                        <ul>
                            <li class="asyncbox_title_icon"></li>
                            <li class="asyncbox_title_tips"><strong>消息提示&nbsp;</strong></li><li style="padding-left: 30px">
                                <a id="qq_1988_close" class="asyncbox_close" href="javascript:void(0)" onclick="hidetip()"
                                    title="关闭">关闭</a></li></ul>
                    </div>
                </td>
                <td class="b_t_r" id="asyncbox_1988_right">
                </td>
            </tr>
            <tr>
                <td class="b_m_l">
                </td>
                <td class="b_m_m">
                    <div id="qq_content" style="overflow: auto; width: 200px; height: 120px;">
                    </div>
                </td>
                <td class="b_m_r">
                </td>
            </tr>
            <tr>
                <td class="b_b_l">
                </td>
                <td id="asyncbox_1988_bottom" class="b_b_m">
                </td>
                <td class="b_b_r">
                </td>
            </tr>
        </tbody>
    </table>
</div>
<div id="loading" style="display: none; position: absolute; left: -1000px; top: -100px;
    width: 221px; height: 40px; border: 1px solid #888888; background: url(/Content/bg-style1.gif);
    z-index: 20000; text-align: center; overflow: hidden;">
    <div style="width: 221px; border: height:20px; font-size: 12px; color: #333333; line-height: 21px;">
        正在处理,请稍后...
        <img src="/Content/images/loading.gif" alt="" />
    </div>
</div>
